﻿<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>通用设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/plugins/layuiadmin/style/admin.css" media="all">
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-body" pad10>
            <div class="layui-form" id="sysconfig">
            <blockquote class="layui-elem-quote" style="margin-top: 3px;">
              <div id="test-util-countdown-ret"><button class="layui-btn layui-btn-normal" data-type="webconfig">站点配置</button>&nbsp;&nbsp;&nbsp;配置站点的各项参数。</div>
            </blockquote>
            <blockquote class="layui-elem-quote" style="margin-top: 3px;">
              <div id="test-util-countdown-ret"><button class="layui-btn layui-btn-warm" data-type="homepath">默认首页</button>&nbsp;&nbsp;&nbsp;设置默认启动的首页路径。</div>
            </blockquote>
            <blockquote class="layui-elem-quote" style="margin-top: 3px;">
              <div id="test-util-countdown-ret"><button class="layui-btn layui-btn-normal" data-type="adminconfig">后台设置</button>&nbsp;&nbsp;&nbsp;后台标题和版权信息的设置。</div>
            </blockquote>
            <blockquote class="layui-elem-quote" style="margin-top: 3px;">
              <div id="test-util-countdown-ret"><button class="layui-btn" data-type="cacheclear">清空缓存</button>&nbsp;&nbsp;&nbsp;清空系统缓存。</div>
            </blockquote>
            <blockquote class="layui-elem-quote" style="margin-top: 3px;">
              <div id="test-util-countdown-ret"><button class="layui-btn layui-btn-danger" data-type="restart">重启系统</button>&nbsp;&nbsp;&nbsp;重新启动系统。</div>
            </blockquote>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <script src="/plugins/layui/layui.js"></script>
  <script type="text/javascript" src="/plugins/common/login.js"></script>
  <script>
      layui.config({
          base: '/plugins/layuiadmin/'
      }).extend({
          index: 'lib/index'
      }).use(['index', 'set'], function () {
          var $ = layui.$;
          var active = {
              webconfig: function () {
                  layer.open({
                    type: 2
                    ,title: '站点配置'
                    ,content: 'web_config.html'
                    ,maxmin: true
                    ,area: ['700px', '600px']
                    ,btn: ['确定', '取消']
                    ,yes: function(index, layero){
                      var submit = layero.find('iframe').contents().find("#btn_submit");
                      submit.trigger('click');
                    }
                  });
              },
              restart: function () {
                  layer.confirm('您确定要重启系统吗？重启系统将重置所有的配置。', function (index) {
                      layer.load();
                      $.ajax({
                          type: "post",
                          url: "sys_config",
                          data: { action: 'restart' },
                          dataType: "json",
                          success: function (res) {
                              layer.closeAll('loading');
                              if (res.code == 0) {
                                  layer.msg(res.msg, { time: 10 * 1000 });
                              }
                              else if (res.code == 110) {
                                  layer.alert(res.msg, function () {
                                      ReLogin();
                                  });
                              }
                              else {
                                  layer.alert(res.msg)
                              }
                          }
                      })
                  })
              },
              cacheclear: function () {
                 layer.confirm('您确定要清空系统缓存吗？', function (index) {
                      layer.load();
                      $.ajax({
                          type: "post",
                          url: "sys_config",
                          data: { action: 'clear' },
                          dataType: "json",
                          success: function (res) {
                              layer.closeAll('loading'); 
                              if (res.code == 0) {
                                  layer.msg(res.msg, { time: 2 * 1000 });
                              }
                              else if (res.code == 110)
                              {
                                layer.alert(res.msg, function () {
                                    ReLogin();
                                });
                              }
                              else {
                                  layer.alert(res.msg)
                              }
                         }
                  });
                });
              },
              homepath: function (index) {
                  layer.open({
                    type: 2
                    ,title: '默认首页设置'
                    ,content: 'home_config.html'
                    ,maxmin: true
                    ,area: ['600px', '300px']
                    ,btn: ['确定', '取消']
                    ,yes: function(index, layero){
                      var submit = layero.find('iframe').contents().find("#btn_submit");
                      submit.trigger('click');
                    }
                 });
              },
              adminconfig: function () {
                  layer.open({
                    type: 2
                    ,title: '后台设置'
                    ,content: 'admin_config.html'
                    ,maxmin: true
                    ,area: ['600px', '300px']
                    ,btn: ['确定', '取消']
                    ,yes: function(index, layero){
                      var submit = layero.find('iframe').contents().find("#btn_submit");
                      submit.trigger('click');
                    }
                  });
              }
          }

          $('#sysconfig').on('click', '.layui-btn', function () {
              var type = $(this).data('type');
              active[type] ? active[type].call(this) : '';
          });
      });
  </script>
</body>
</html>